<?php
namespace App\Models\Resources;

use App\Models\Enum\SurveyEnum;
use Illuminate\Http\Resources\Json\JsonResource;

class SurveyResource extends JsonResource
{
    public function toArray($request)
    {
        switch ($this->status){
            case -1:
                $this->status = '已删除';//deleted
                break;
            case 0:
                $this->status = '正常';//enable
                break;
            case 1:
                $this->status = '冻结';//disable
                break;
        }
        return [
            'id'=>$this->id,
            'name' => $this->name,
            'status' => SurveyEnum::getStatusName($this->status),
            'description'=>(string)$this->description,
            'start_time'=>(string)$this->start_time,
            'end_time'=>(string)$this->end_time,
            'sheet_count'=>(string)$this->sheet_count,
            'company_id'=>(string)$this->company_id,
            'create_id'=>(string)$this->create_id,
            'create_at'=>(string)$this->create_at,
            'update_at'=>(string)$this->update_at,
        ];
    }
}
